home *** CD-ROM | disk | FTP | other *** search
- *** /home/bammi/etc/src/patch/common.h Tue Sep 29 16:45:36 1992
- --- common.h Tue Sep 29 16:56:34 1992
- ***************
- *** 61,66 ****
- --- 61,67 ----
- #define MAXHUNKSIZE 100000 /* is this enough lines? */
- #define INITHUNKMAX 125 /* initial dynamic allocation size */
- #define MAXLINELEN 1024
- + #ifndef atarist
- #define BUFFERSIZE 1024
-
- #define SCCSPREFIX "s."
- ***************
- *** 70,75 ****
- --- 71,80 ----
- #define RCSSUFFIX ",v"
- #define CHECKOUT "co -l %s"
- #define RCSDIFF "rcsdiff %s > /dev/null"
- + #else
- + extern unsigned long __DEFAULT_BUFSIZ__;
- + #define BUFFERSIZE __DEFAULT_BUFSIZ__
- + #endif
-
- #ifdef FLEXFILENAMES
- #define ORIGEXT ".orig"
- ***************
- *** 97,103 ****
- --- 102,113 ----
-
- typedef char bool;
- typedef long LINENUM; /* must be signed */
- + #ifndef atarist
- typedef unsigned MEM; /* what to feed malloc */
- + #else
- + #include <stddef.h>
- + typedef size_t MEM; /* what to feed malloc */
- + #endif
-
- /* globals */
-
- ***************
- *** 109,115 ****
- --- 119,129 ----
- EXT struct stat filestat; /* file statistics area */
- EXT int filemode INIT(0644);
-
- + #ifndef atarist
- EXT char buf[MAXLINELEN]; /* general purpose buffer */
- + #else
- + EXT char buf[32768]; /* general purpose buffer */
- + #endif
- EXT FILE *ofp INIT(Nullfp); /* output file pointer */
- EXT FILE *rejfp INIT(Nullfp); /* reject file pointer */
-
- ***************
- *** 164,169 ****
- --- 178,186 ----
- EXT char end_defined[128]; /* #endif xyzzy */
-
- EXT char *revision INIT(Nullch); /* prerequisite revision, if any */
- + #ifdef NODIR
- + EXT char *simple_backup_suffix INIT("~");
- + #endif
-
- #include <errno.h>
- #ifndef errno
- ***************
- *** 170,175 ****
- --- 187,193 ----
- extern int errno;
- #endif
-
- + #ifndef atarist
- FILE *popen();
- char *malloc();
- char *realloc();
- ***************
- *** 180,185 ****
- --- 198,211 ----
- char *rindex();
- long lseek();
- char *mktemp();
- + char *getenv();
- + #else
- + #include <string.h>
- + #include <memory.h>
- + #include <unistd.h>
- + EXT unsigned long __DEFAULT_BUFSIZ__ INIT(64*1024L);
- + #endif
- +
- #if 0 /* This can cause a prototype conflict. */
- #ifdef CHARSPRINTF
- char *sprintf();
- ***************
- *** 187,193 ****
- int sprintf();
- #endif
- #endif
- -
- #if !defined(S_ISDIR) && defined(S_IFDIR)
- #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
- #endif
- --- 213,218 ----
- *** /home/bammi/etc/src/patch/inp.c Tue Sep 29 16:45:36 1992
- --- inp.c Tue Sep 29 17:04:48 1992
- ***************
- *** 90,95 ****
- --- 90,96 ----
- statfailed = stat(filename, &filestat);
- }
- /* For nonexistent or read-only files, look for RCS or SCCS versions. */
- + #ifndef atarist
- if (statfailed
- /* No one can write to it. */
- || (filestat.st_mode & 0222) == 0
- ***************
- *** 145,150 ****
- --- 146,155 ----
- fatal3("can't check out file %s from %s\n", filename, cs);
- }
- }
- + #else
- + if(statfailed)
- + fatal2("Can't find %s.\n", filename);
- + #endif
- filemode = filestat.st_mode;
- if (!S_ISREG(filemode))
- fatal2("%s is not a normal file--can't patch\n", filename);
- *** /home/bammi/etc/src/patch/patch.c Tue Sep 29 16:45:36 1992
- --- patch.c Tue Sep 29 16:50:06 1992
- ***************
- *** 138,143 ****
- --- 138,147 ----
- int failtotal = 0;
- int i;
-
- + #ifdef atarist
- + _binmode(1);
- + stdin->_flag |= _IOBIN; /* sorry! */
- + #endif
- setbuf(stderr, serrbuf);
- for (i = 0; i<MAXFILEC; i++)
- filearg[i] = Nullch;
- ***************
- *** 151,156 ****
- --- 155,167 ----
- int tmpname_len;
-
- tmpdir = getenv ("TMPDIR");
- + #ifdef atarist
- + if (tmpdir == (char *)0) {
- + tmpdir = getenv ("TEMP");
- + if (tmpdir == (char *)0)
- + tmpdir = getenv ("TMP");
- + }
- + #endif
- if (tmpdir == NULL) {
- tmpdir = "/tmp";
- }
- ***************
- *** 157,179 ****
- --- 168,222 ----
- tmpname_len = strlen (tmpdir) + 20;
-
- TMPOUTNAME = (char *) malloc (tmpname_len);
- + #ifdef atarist
- + strcpy (TMPOUTNAME, tmpdir);
- + if (TMPOUTNAME[strlen (TMPOUTNAME) - 1] == '/' ||
- + TMPOUTNAME[strlen (TMPOUTNAME) - 1] == '\\')
- + TMPOUTNAME[strlen (TMPOUTNAME) - 1] = '\0';
- + strcat (TMPOUTNAME, "/patoXXXX");
- + #else
- strcpy (TMPOUTNAME, tmpdir);
- strcat (TMPOUTNAME, "/patchoXXXXXX");
- + #endif
- Mktemp(TMPOUTNAME);
-
- TMPINNAME = (char *) malloc (tmpname_len);
- + #ifdef atarist
- + strcpy (TMPINNAME, tmpdir);
- + if (TMPINNAME[strlen (TMPINNAME) - 1] == '/' ||
- + TMPINNAME[strlen (TMPINNAME) - 1] == '\\')
- + TMPINNAME[strlen (TMPINNAME) - 1] = '\0';
- + strcat (TMPINNAME, "/patiXXXX");
- + #else
- strcpy (TMPINNAME, tmpdir);
- strcat (TMPINNAME, "/patchiXXXXXX");
- + #endif
- Mktemp(TMPINNAME);
-
- TMPREJNAME = (char *) malloc (tmpname_len);
- + #ifdef atarist
- + strcpy (TMPREJNAME, tmpdir);
- + if (TMPREJNAME[strlen (TMPREJNAME) - 1] == '/' ||
- + TMPREJNAME[strlen (TMPREJNAME) - 1] == '\\')
- + TMPREJNAME[strlen (TMPREJNAME) - 1] = '\0';
- + strcat (TMPREJNAME, "/patrXXXX");
- + #else
- strcpy (TMPREJNAME, tmpdir);
- strcat (TMPREJNAME, "/patchrXXXXXX");
- + #endif
- Mktemp(TMPREJNAME);
-
- TMPPATNAME = (char *) malloc (tmpname_len);
- + #ifdef atarist
- + strcpy (TMPPATNAME, tmpdir);
- + if (TMPPATNAME[strlen (TMPPATNAME) - 1] == '/' ||
- + TMPPATNAME[strlen (TMPPATNAME) - 1] == '\\')
- + TMPPATNAME[strlen (TMPPATNAME) - 1] = '\0';
- + strcat (TMPPATNAME, "/patpXXXX");
- + #else
- strcpy (TMPPATNAME, tmpdir);
- strcat (TMPPATNAME, "/patchpXXXXXX");
- + #endif
- Mktemp(TMPPATNAME);
- }
-
- ***************
- *** 368,373 ****
- --- 411,441 ----
- if (failed) {
- failtotal += failed;
- if (!*rejname) {
- + #ifdef atarist
- + char *rindex();
- + char *dot, *slash;
- +
- + Strcpy(rejname, outname);
- + if ((slash = rindex(rejname, '\\')) ||
- + (slash = rindex(rejname, '/')))
- + slash++;
- + else
- + slash = rejname;
- + if (dot = rindex(slash, '.')) {
- + dot++;
- + if (strlen(dot) >= 3)
- + Strcpy(&dot[2], REJEXT);
- + else
- + Strcat(dot, REJEXT);
- + } else {
- + if (strlen(slash) > 8)
- + Strcpy(&slash[8], ".");
- + else {
- + Strcat(slash, ".");
- + }
- + Strcat(slash, REJEXT);
- + }
- + #else /* atarist */
- Strcpy(rejname, outname);
- #ifndef FLEXFILENAMES
- {
- ***************
- *** 382,387 ****
- --- 450,456 ----
- }
- #endif
- Strcat(rejname, REJEXT);
- + #endif /* !atarist */
- }
- if (skip_rest_of_patch) {
- say4("%d out of %d hunks ignored--saving rejects to %s\n",
- *** /home/bammi/etc/src/patch/pch.c Tue Sep 29 16:45:36 1992
- --- pch.c Tue Sep 29 16:50:07 1992
- ***************
- *** 730,740 ****
- --- 730,743 ----
-
- if (diff_type == CONTEXT_DIFF &&
- (fillcnt || (p_first > 1 && ptrn_copiable > 2*p_context)) ) {
- + #ifndef atarist /* unfortunately this is always true for TOS because of
- + the ^M at the end of a line -- just ignore warning */
- if (verbose)
- say4("%s\n%s\n%s\n",
- "(Fascinating--this is really a new-style context diff but without",
- "the telltale extra asterisks on the *** line that usually indicate",
- "the new style...)");
- + #endif
- diff_type = NEW_CONTEXT_DIFF;
- }
-
- ***************
- *** 1241,1246 ****
- --- 1244,1250 ----
- return p_hunk_beg;
- }
-
- + #ifndef atarist
- /* Apply an ed script by feeding ed itself. */
-
- void
- ***************
- *** 1303,1305 ****
- --- 1307,1317 ----
- chmod(outname, filemode);
- set_signals(1);
- }
- + #else
- + void
- + do_ed_script()
- + {
- + fprintf(stderr,"Sorry! TOS version of Patch cannot deal with ed scripts\n");
- + exit(999);
- + }
- + #endif
- *** /home/bammi/etc/src/patch/util.c Tue Sep 29 16:45:36 1992
- --- util.c Tue Sep 29 17:30:29 1992
- ***************
- *** 48,54 ****
- }
-
- if (origprae) {
- ! Strcpy(bakname, origprae);
- Strcat(bakname, to);
- } else {
- #ifndef NODIR
- --- 48,54 ----
- }
-
- if (origprae) {
- ! Strcpy(bakname, origprae);
- Strcat(bakname, to);
- } else {
- #ifndef NODIR
- ***************
- *** 58,65 ****
- Strcpy(bakname, backupname);
- free(backupname);
- #else /* NODIR */
- Strcpy(bakname, to);
- ! Strcat(bakname, simple_backup_suffix);
- #endif /* NODIR */
- }
-
- --- 58,91 ----
- Strcpy(bakname, backupname);
- free(backupname);
- #else /* NODIR */
- + #ifdef atarist
- + char *rindex();
- + char *dot, *slash;
- +
- Strcpy(bakname, to);
- ! if ((slash = rindex(bakname, '\\')) ||
- ! (slash = rindex(bakname, '/')))
- ! slash++;
- ! else
- ! slash = bakname;
- ! if (dot = rindex(slash, '.')) {
- ! dot++;
- ! if (strlen(dot) >= 3)
- ! Strcpy(&dot[2], ORIGEXT);
- ! else
- ! Strcat(dot, ORIGEXT);
- ! } else {
- ! if (strlen(slash) > 8)
- ! Strcpy(&slash[8], ".");
- ! else {
- ! Strcat(slash, ".");
- ! }
- ! Strcat(slash, ORIGEXT);
- ! }
- ! #else /* atarist */
- ! Strcpy(bakname, to);
- ! Strcat(bakname, simple_backup_suffix);
- ! #endif /* !atarist */
- #endif /* NODIR */
- }
-
- ***************
- *** 89,94 ****
- --- 115,123 ----
- if (debug & 4)
- say3("Moving %s to %s.\n", to, bakname);
- #endif
- + #ifdef atarist
- + copy_file(to, bakname);
- + #else
- if (link(to, bakname) < 0) {
- /* Maybe `to' is a symlink into a different file system.
- Copying replaces the symlink with a file; using rename
- ***************
- *** 111,123 ****
- --- 140,159 ----
- Close(tofd);
- Close(bakfd);
- }
- + #endif
- while (unlink(to) >= 0) ;
- }
- +
- #ifdef DEBUGGING
- if (debug & 4)
- say3("Moving %s to %s.\n", from, to);
- #endif
- +
- + #ifndef atarist
- if (link(from, to) < 0) { /* different file system? */
- + #else
- + if (1) {
- + #endif
- Reg4 int tofd;
-
- tofd = creat(to, 0666);
- ***************
- *** 253,258 ****
- --- 289,297 ----
-
- Sprintf(buf, pat, arg1, arg2, arg3);
- Fflush(stderr);
- + #ifdef atarist
- + r = _tos_ask(buf);
- + #else
- write(2, buf, strlen(buf));
- if (tty2) { /* might be redirected to a file */
- r = read(2, buf, sizeof buf);
- ***************
- *** 277,282 ****
- --- 316,322 ----
- buf[0] = '\n';
- r = 1;
- }
- + #endif
- if (r <= 0)
- buf[0] = 0;
- else
- ***************
- *** 429,434 ****
- --- 469,475 ----
- free(fullname);
-
- if (stat(name, &filestat) && !assume_exists) {
- + #ifndef atarist
- char *filebase = basename(name);
- int pathlen = filebase - name;
-
- ***************
- *** 442,447 ****
- --- 483,489 ----
- || try("SCCS/%s%s", SCCSPREFIX, filebase)
- || try( "%s%s", SCCSPREFIX, filebase))
- return name;
- + #endif
- free(name);
- name = Nullch;
- }
- ***************
- *** 448,450 ****
- --- 490,538 ----
-
- return name;
- }
- +
- + #ifdef atarist
- + /* this kludge is necessary because stdin is most likely re-directed
- + and there is no way to read from CON: due to the braindamage
- + in handles -- thanks Atari
- + */
- + #undef Fclose
- + #undef Fseek
- + #include <osbind.h>
- + int _tos_ask(buf)
- + char *buf;
- + {
- + /* have to el-kludge it */
- + int c;
- + int r = 0;
- + char *p = buf;
- +
- + write(2, buf, strlen(buf));
- +
- + while(( c = (Bconin(2) & 0x7f)) != '\r')
- + {
- + switch(c)
- + { /* we dont handle tabs/control chars nicely here */
- + case 0:
- + break;
- + case '\b':
- + case 0177:
- + if(r > 0)
- + { --p; --r; }
- + Bconout(2, '\b'); Bconout(2, ' '); Bconout(2, '\b');
- + break;
- + default:
- + if(c >= ' ')
- + {
- + *p++ = c; r++;
- + Bconout(2, c);
- + }
- + /* else ignore control chars/tabs */
- + }
- + }
- + Bconout(2, '\r');
- + Bconout(2, '\n');
- + *p++ = '\n'; *p = '\0';
- + return r+1;
- + }
- + #endif
-